

import java.awt.BorderLayout;

import javax.swing.*;

public class RoundDemo extends JFrame {

	private static final long serialVersionUID = 8632674610279650825L;
	private static final int WIDTH = 800;
	private static final int HEIGHT = 800;
	
	/* MESS WITH THE VALUES BELOW TO SEE DIFFERENT PAYOUT RESULTS */
	
	//static int round = 1;
	//static int players = 0;
	static double alpha = .5;
	static double A = 1;
	static double B = 0;
	static double Endowed = 2000;
	static double pratio = .5;
	static double pthresh = 1000;
	static double othersEndowed = 5000;
	static int roundNum = 1;
	
	/* VALUES END HERE!! */
	
	public RoundDemo() {
		super();
		setSize(WIDTH, HEIGHT);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		BorderLayout bl = new BorderLayout();
		setLayout(bl);
		setVisible(true);
		
		//ratio -- threshold -- endowment -- index
		Pledge demo = new Pledge(0, 0, Endowed, 0);
		
		RoundPane gpane = new RoundPane(demo, othersEndowed, A, B, alpha, roundNum);
		
		add(gpane);

	}
	
	//asks questions to set up the axis and other starting info
	public static void setupGame() {
		String info;
		
		info = JOptionPane.showInputDialog("Payoff = A*(moneyLeft)^(1-alpha)*G^alpha+B\nWhat is A?");
		try {
			A  = new Double(info);
			if (A < 0) System.exit(0);
		} catch (NumberFormatException e) {
			System.err.println("Invalid number for A.");
			System.exit(0);
		}
		
		info = JOptionPane.showInputDialog("Payoff = A*(moneyLeft)^(1-alpha)*G^alpha+B\nWhat is B?");
		try {
			B  = new Double(info);
			if (B < 0) System.exit(0);
		} catch (NumberFormatException e) {
			System.err.println("Invalid number for B.");
			System.exit(0);
		}
		
		info = JOptionPane.showInputDialog("Payoff = A*(moneyLeft)^(1-alpha)*G^alpha+B\nWhat is alpha?");
		try {
			alpha  = new Double(info);
			if (alpha < 0) System.exit(0);
		} catch (NumberFormatException e) {
			System.err.println("Invalid number for alpha.");
			System.exit(0);
		}
		
		info = JOptionPane.showInputDialog("How much were YOU given to start with?\nThis will be used to decide the Y-AXIS");
		try {
			Endowed  = new Double(info);
			if (Endowed < 0) System.exit(0);
		} catch (NumberFormatException e) {
			System.err.println("Invalid number for Endowed.");
			System.exit(0);
		}
		
		info = JOptionPane.showInputDialog("How much (total) were the OTHERS given to start with?\nThis will be used to decide the X-AXIS");
		try {
			othersEndowed  = new Double(info);
			if (othersEndowed < 0) System.exit(0);
		} catch (NumberFormatException e) {
			System.err.println("Invalid number for othersEndowed.");
			System.exit(0);
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//setupGame() can be commented out to use default values
		//setupGame();
		RoundDemo gd = new RoundDemo();
		gd.setVisible(true);
	}

}
